import * as Action from '../../../store/action/actionTask'
import {connect} from 'react-redux'

function TaskItem(props) {
    const {item,index,handleDelete} = props
    const {task,date} = item

    return (
        <li >
            <span>{index+1}-{task}--{date}</span>{' '}
            <button onClick={()=>{
              handleDelete(index)
            }}>delete</button>
        </li>
    )
  }
  
  const mapDispatch  = dispatch =>({
    handleDelete:(index)=>dispatch(Action.deleteAction(index))
  })

 export default connect(null,mapDispatch)(TaskItem)